home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 2001 September / PC-WELT 9-2001.ISO / software / hw / brennen / flask_src.exe / Audio / AC3 / AC3Dec / sanity_check.c < prev    next >
Encoding:
C/C++ Source or Header  |  2000-05-06  |  3.4 KB  |  132 lines

  1. /* 
  2.  *  sanity_check.c
  3.  *
  4.  *    Copyright (C) Aaron Holtzman - May 1999
  5.  *
  6.  *  This file is part of ac3dec, a free Dolby AC-3 stream decoder.
  7.  *    
  8.  *  ac3dec is free software; you can redistribute it and/or modify
  9.  *  it under the terms of the GNU General Public License as published by
  10.  *  the Free Software Foundation; either version 2, or (at your option)
  11.  *  any later version.
  12.  *   
  13.  *  ac3dec is distributed in the hope that it will be useful,
  14.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  15.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16.  *  GNU General Public License for more details.
  17.  *   
  18.  *  You should have received a copy of the GNU General Public License
  19.  *  along with GNU Make; see the file COPYING.  If not, write to
  20.  *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 
  21.  *
  22.  */
  23.  
  24. #include <stdlib.h>
  25. #include <stdio.h>
  26. #include "ac3.h"
  27. #include "ac3_internal.h"
  28. #include "sanity_check.h"
  29.  
  30.  
  31. void 
  32. sanity_check_init(syncinfo_t *syncinfo, bsi_t *bsi, audblk_t *audblk)
  33. {
  34.     syncinfo->magic = AC3_MAGIC_NUMBER;
  35.     bsi->magic = AC3_MAGIC_NUMBER;
  36.     audblk->magic1 = AC3_MAGIC_NUMBER;
  37.     audblk->magic2 = AC3_MAGIC_NUMBER;
  38.     audblk->magic3 = AC3_MAGIC_NUMBER;
  39. }
  40.  
  41. void 
  42. sanity_check(syncinfo_t *syncinfo, bsi_t *bsi, audblk_t *audblk)
  43. {
  44.     int i;
  45.  
  46.     if(syncinfo->magic != AC3_MAGIC_NUMBER)
  47.     {
  48.         fprintf(stderr,"\n** Sanity check failed -- syncinfo magic number **");
  49.         error_flag = 1;
  50.     }
  51.     
  52.     if(bsi->magic != AC3_MAGIC_NUMBER)
  53.     {
  54.         fprintf(stderr,"\n** Sanity check failed -- bsi magic number **");
  55.         error_flag = 1;
  56.     }
  57.  
  58.     if(audblk->magic1 != AC3_MAGIC_NUMBER)
  59.     {
  60.         fprintf(stderr,"\n** Sanity check failed -- audblk magic number 1 **"); 
  61.         error_flag = 1;
  62.     }
  63.  
  64.     if(audblk->magic2 != AC3_MAGIC_NUMBER)
  65.     {
  66.         fprintf(stderr,"\n** Sanity check failed -- audblk magic number 2 **"); 
  67.         error_flag = 1;
  68.     }
  69.  
  70.     if(audblk->magic3 != AC3_MAGIC_NUMBER)
  71.     {
  72.         fprintf(stderr,"\n** Sanity check failed -- audblk magic number 3 **"); 
  73.         error_flag = 1;
  74.     }
  75.  
  76.     for(i = 0;i < 5 ; i++)
  77.     {
  78.         if (audblk->fbw_exp[i][255] !=0 || audblk->fbw_exp[i][254] !=0 || 
  79.                 audblk->fbw_exp[i][253] !=0)
  80.         {
  81.             fprintf(stderr,"\n** Sanity check failed -- fbw_exp out of bounds **"); 
  82.             error_flag = 1;
  83.         }
  84.  
  85.         if (audblk->fbw_bap[i][255] !=0 || audblk->fbw_bap[i][254] !=0 || 
  86.                 audblk->fbw_bap[i][253] !=0)
  87.         {
  88.             fprintf(stderr,"\n** Sanity check failed -- fbw_bap out of bounds **"); 
  89.             error_flag = 1;
  90.         }
  91.  
  92.     }
  93.  
  94.     if (audblk->cpl_exp[255] !=0 || audblk->cpl_exp[254] !=0 || 
  95.             audblk->cpl_exp[253] !=0)
  96.     {
  97.         fprintf(stderr,"\n** Sanity check failed -- cpl_exp out of bounds **"); 
  98.         error_flag = 1;
  99.     }
  100.  
  101.     if (audblk->cpl_bap[255] !=0 || audblk->cpl_bap[254] !=0 || 
  102.             audblk->cpl_bap[253] !=0)
  103.     {
  104.         fprintf(stderr,"\n** Sanity check failed -- cpl_bap out of bounds **"); 
  105.         error_flag = 1;
  106.     }
  107.  
  108.     if (audblk->cplmant[255] !=0 || audblk->cplmant[254] !=0 || 
  109.             audblk->cplmant[253] !=0)
  110.     {
  111.         fprintf(stderr,"\n** Sanity check failed -- cpl_mant out of bounds **"); 
  112.         error_flag = 1;
  113.     }
  114.  
  115.     if ((audblk->cplinu == 1) && (audblk->cplbegf > (audblk->cplendf+2)))
  116.     {
  117.         fprintf(stderr,"\n** Sanity check failed -- cpl params inconsistent **"); 
  118.         error_flag = 1;
  119.     }
  120.  
  121.     for(i=0; i < bsi->nfchans; i++)
  122.     {
  123.         if((audblk->chincpl[i] == 0) && (audblk->chbwcod[i] > 60))
  124.         {
  125.             fprintf(stderr,"\n** Sanity check failed -- chbwcod too big **"); 
  126.             error_flag = 1;
  127.         }
  128.     }
  129.  
  130.     return;
  131. }    
  132.